package com.hefei.user.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.hefei.api.customer.manager.IUserManager;
import com.hefei.api.customer.manager.impl.UserManager;
import com.hefei.api.customer.vo.SysMenu;
import com.hefei.api.customer.vo.User;
import com.hefei.api.customer.vo.easyui.PageHelper;
import com.hefei.common.exception.ClientException;
import com.hefei.user.service.IUserService;

@Service
public class UserService implements IUserService {
	
	private Logger logger = Logger.getLogger(UserService.class);
	
	private IUserManager userManager = new UserManager();

	@Override
	public User findUserByName(String username) {
		
		try {
			userManager.login(username);
		} catch (ClientException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<SysMenu> getMenu(int userId) {

		return userManager.getMenuByUserId(userId);
	}

	@Override
	public List<User> datagridUser(PageHelper page, Integer sysid) {
		page.setStart((page.getPage()-1)*page.getRows());
		page.setEnd(page.getPage()*page.getRows());
		return userManager.datagridUser(page,sysid); 
	}

	@Override
	public Long getDatagridTotal(User user, Integer sysid) {
		// TODO Auto-generated method stub
		return userManager.getDatagridTotal(user,sysid); 
	}
	
	

}
